/*
Autor: Alexander Savochkin, 2010-2013
New BSD License
*/

#pragma once

#include <string>
#include <map>

using std::map;
using std::string;

#include "IOperatedInput.h"
#include "OperatedInputFactory.h"

#include "IOperatedOutput.h"
#include "OperatedOutputFactory.h"

#include "IRegulator.h"
#include "RegulatorFactory.h"

#include "Config.h"

using std::string;

namespace SRCLF {

using IO::OperatedInputFactory;
using IO::OperatedOutputFactory;
using Control::RegulatorFactory;

using IO::IOperatedInput;
using IO::IOperatedOutput;
using Control::IRegulator;

using Config::Configuration;

	class FactoriesKeeper
	{
		FactoriesKeeper();
		~FactoriesKeeper();

		map<string, RegulatorFactory* > regulator_factories;
		map<string, OperatedInputFactory* > operated_input_factories;
		map<string, OperatedOutputFactory* > operated_output_factories;
	public:
		static FactoriesKeeper& getInstance();

		OperatedInputFactory* getInputFactory(const string& object_registered_type_name);
		OperatedOutputFactory* getOutputFactory(const string& object_registered_type_name);
		RegulatorFactory* getRegulatorFactory(const string& object_registered_type_name);

		IOperatedInput* newInputInstance(const string& name, const Configuration& config);
		IOperatedOutput* newOutputInstance(const string& name, const Configuration& config);
		IRegulator* newRegulatorInstance(const string& name, const Configuration& config);

		bool registerRegulatorFactory(const string&, RegulatorFactory*);
		bool registerInputFactory(const string&, OperatedInputFactory*);
		bool registerOutputFactory(const string&, OperatedOutputFactory*);
	};

} //namespace SRCLF
